<script>
    //1、去除数组中重复元素
    let array1=[1,1,2,2,88,88,9,1,2];
    let array2=[...new Set(array1)];  //先实例化一个Set集合去重复，再展开set初始化数组
    console.log(array2);

    //2、并集
    var a1=["a","b","c","d"];
    var a2=["c","d","e","f"];
    var a3=[...new Set([...a1,...a2])];
    console.log(a3);

    //3、交集
    let s2=new Set(a2);
    let a4=a1.filter(v=>s2.has(v));  //过滤a1中的元素，如果存在a2中则保留
    console.log(a4);

    //4、差集，a1->a2
    let a5=a1.filter(v=>!s2.has(v));  //过滤a1中的元素，如果不存在a2中则保留
    console.log(a5);
</script>